<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>

  <!-- and it's easy to individually load additional languages -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/go.min.js"></script>

  <script>hljs.highlightAll();</script>
</head>
<div class="container" style="background-color: #f3f3f3;">
  <!-- 代码预览 -->
   <div style="flex: 1; padding: 5px;">
    <h2>代码</h2>
    <pre>
      <code>
        $str1="abcdefghijkd";<br>
        $pos=strrpos($str1, "d");<br>
        echo $pos;  // 获取字符串下标，从0开始，返回最后一次出现的位置<br>
        <br><hr>

        $str2="字a符b串1长2度";<br>
        echo strlen($str2);<br>
        <br><hr>

        $str3='applepearpeach';<br>
        $sub1=substr($str3,0,5);<br>
        $sub2=substr($str3,-5,5);<br>
        $sub3=substr($str3,0,-5);<br>
        // 字符串切片
        echo $sub1;<br>
        echo $sub2;<br>
        echo $sub3;<br>

        <br><hr>

        $str4='piece1 piece2 piece3 piece4';<br>
        $sep1=explode(" ", $str4);<br>
        // 用空格符讲字符串分割为数组<br>
        var_dump($sep1);<br>
        echo $sep1[0],'<br>',$sep1[3];<br>


        $str5="newfile.php";<br>
        $sep2=explode(".",$str5);<br>
        var_dump($sep2);<br>
        echo $sep2[0],'<br>',$sep2[1];


        $str6=array('newfile','php');<br>
        // 用explode切割，用implode讲数组拼接<br>
        $cons=implode(".",$str6);<br>
        echo $cons;<br>
      </code>
    </pre>
   </div>
  

  <!-- 代码输出 -->
   <div style="flex: 1; padding: 5px; color: black; background-color: #fff; height: 100%;">
      <h2 style="color: green;">php 输出效果</h2>
     <pre>
       <?php
        $str1="abcdefghijkd";
        $pos=strrpos($str1, "d");
        echo $pos;  // 获取字符串下标，从0开始，返回最后一次出现的位置
        echo "<br><hr>";
   
        $str2="字a符b串1长2度";
        echo strlen($str2);
        echo "<br><hr>";
   
        $str3='applepearpeach';
        $sub1=substr($str3,0,5);
        $sub2=substr($str3,-5,5);
        $sub3=substr($str3,0,-5);
       // 字符串切片
        echo $sub1,'<br>';
        echo $sub2,'<br>';
        echo $sub3,'<br>';
   
        echo "<br><hr>";
   
        $str4='piece1 piece2 piece3 piece4';
        $sep1=explode(" ", $str4);
       // 用空格符讲字符串分割为数组
        var_dump($sep1);
        echo $sep1[0],'<br>',$sep1[3];
   
        echo "<br><hr>";
   
        $str5="newfile.php";
        $sep2=explode(".",$str5);
        var_dump($sep2);
        echo $sep2[0],'<br>',$sep2[1];
   
        echo "<br><hr>";
   
        $str6=array('newfile','php');
       // 用explode切割，用implode讲数组拼接
       $cons=implode(".",$str6);
       echo $cons;
       ?>
     </pre>
   </div>
</div>


<style>
  .container {
    display: flex;
  }
</style>